<?php

class Modulo{
	
	public $bd;
	public $resultado;

	
	public function __construct(){
		
		$this->bd = new Basedatos();
		
	}
		public function mostrar_modulo(){
		
		$query = "CALL ConsultarTodosModulo()";
		$this->result = $this->bd->select($query);
		return $this->result;		
		
	}
		public function mostrar_modulo_uno($id){
		
		$query = "CALL ConsultarUnModulo('".$id."')";
		$this->result = $this->bd->select($query);
		return $this->result;		
		
	}
		public function editar_modulo($idcod, $nombre, $descripcion, $link){
		
		$query = "CALL ModificarModulo('".$idcod."','".$nombre."','".$descripcion."','".$link."')";
		$this->result = $this->bd->update($query);	
		/*Esto es kawaii*/
		
	}
		public function insertar_modulo($nombre, $desc, $link){
		echo $nombre;
		echo $desc;
		echo $link;
		$query = "CALL IngresarModulo('".$nombre."','".$desc."','".$link."')";
		$this->result  = $this->bd->insert($query);
		
	}
		public function existe_modulo(){
			$query = "CALL ExisteCargo(id_modulo,".$existe.")";
			$this->result = $this->bd->select($query);
			return $existe;
		}
		public function eliminar_modulo($id){
			$query = "CALL EliminarModulo(".$id.")";
			$this->result = $this->bd->delete($query);
		}
		public function mostrar_modulo_na($id){
		$query = "CALL ConsultarModulosDeNivelAcceso($id)";
		$this->result = $this->bd->select($query);
		return $this->result;
	}
		public function relacion_mna($id){
			$query = "CALL RelMNAModulo($id)";
			$this->result = $this->bd->select($query);
			$row=mysql_fetch_array($this->result);
			if ($row['contador'] > 0){
				$res = true;
			}else{
				$res = false;
			}
			return $res;

		}
		public function cons_mod_na($id){
			$query = "CALL ConsultarModulosDeNivelAcceso($id)";
			$this->result = $this->bd->select($query);
			return $this->result;		
		}
		public function cons_mod_nona($id){
			$query = "CALL ConsultarModulosNoEnNivelAcceso($id)";
			$this->result = $this->bd->select($query);
			return $this->result;		
		}
		


}
?>